#include "PrimitiveDataManagerTest.h"
#include <models/PrimitiveDataManager.h>
#include <sys/time.h>

TEST_F(PrimitiveDataManagerTest, normal_test)
{
    PrimitiveDataManager& manager = PrimitiveDataManager::get_instance();
    ASSERT_EQ(0, manager.get_primitive_data(100).i_part);
    ASSERT_EQ(0, manager.get_primitive_data(100).d_part);

    PrimitiveData data = {123456, 78, 0, 0};
    
    timeval now;
    gettimeofday(&now, nullptr);
    data.update_time = now.tv_sec;
    data.milliseconds = now.tv_usec / 1000;
    manager.set_primitive_data(100, data);

    ASSERT_EQ(123456, manager.get_primitive_data(100).i_part);
    ASSERT_EQ(78, manager.get_primitive_data(100).d_part);
    ASSERT_EQ(now.tv_sec, manager.get_primitive_data(100).update_time);
    ASSERT_EQ(now.tv_usec / 1000, manager.get_primitive_data(100).milliseconds);
}